package logic

import (
	"context"
	redis2 "gitee.com/Cauchy_AQ/vxopen/model/redis"
	"gitee.com/Cauchy_AQ/vxopen/utils"

	"gitee.com/Cauchy_AQ/vxopen/rpc/transform/internal/svc"
	"gitee.com/Cauchy_AQ/vxopen/rpc/transform/transform"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserMaxOnlineLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserMaxOnlineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserMaxOnlineLogic {
	return &UserMaxOnlineLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserMaxOnlineLogic) UserMaxOnline(in *transform.UserMaxOnlineReq) (*transform.UserMaxOnlineResp, error) {
	_, _ = l.svcCtx.RDB.Set(context.Background(), redis2.CacheMaxOnlinePrefix+utils.GetTodayFormat(), in.Online, redis2.CacheMaxOnlinePrefixTimeout).Result()
	return &transform.UserMaxOnlineResp{}, nil
}
